package com.lawliet.example.controller.system;

import com.lawliet.example.model.system.SysNotice;
import com.lawliet.example.model.vo.Result;
import com.lawliet.example.service.system.SysNoticeService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "SysNotice 接口")
@RestController
@RequestMapping("/api/sysNotice")
public class SysNoticeController {
    @Autowired
    private SysNoticeService sysNoticeService;

    @GetMapping("/list")
    public Result<List<SysNotice>> list() {
        return Result.OK(sysNoticeService.list());
    }

    @PostMapping("/add")
    public Result<?> add(@RequestBody SysNotice sysNotice) {
        return Result.OK(sysNoticeService.save(sysNotice));
    }

    @PutMapping("/edit")
    public Result<?> edit(@RequestBody SysNotice sysNotice) {
        return Result.OK(sysNoticeService.updateById(sysNotice));
    }

    @DeleteMapping("/delete/{id}")
    public Result<?> delete(@PathVariable Long id) {
        return Result.OK(sysNoticeService.removeById(id));
    }

    @GetMapping("/query/{id}")
    public Result<SysNotice> queryById(@PathVariable Long id) {
        return Result.OK(sysNoticeService.getById(id));
    }
}
